public class Solution268 {
    public int missingNumber(int[] nums) {
        int n=nums.length;
        int total=n*(n+1)/2;
        for (int num : nums) {
            total=total-num;
        }
        return total;
    }

    public static void main(String[] args) {
        System.out.println(new Solution268().missingNumber(new int[]{3,0,1}));
    }
}
